package com.hainatong.jcmvvmbase.login.viewmodel;

import android.app.Application;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import androidx.lifecycle.MutableLiveData;
import com.hainatong.jcmvvmbase.repository.DataRepository;
import com.hainatong.mvvmbase.base.BaseViewModel;

public class PasswordViewModel extends BaseViewModel
{

    // Xml 布局文件中 @{ viewmodel.username } 是单向绑定
    // @={ viewmodel.username } 是双向绑定
    public final ObservableField<String> oldPwd = new ObservableField<>();
    public final ObservableField<String> newPwd = new ObservableField<>();
    public final ObservableField<String> newPwd2 = new ObservableField<>();

    public PasswordViewModel(@NonNull Application application)
    {
        super(application);
    }

    public MutableLiveData<Boolean> updatePasswOrder()
    {
        return DataRepository.getInstance().getRepository().updatePwd(this.newPwd.get());
    }

    @Override
    protected void onCleared()
    {
        super.onCleared();
        DataRepository.getInstance().getRepository().unDisposable();
    }
}
